Step 1 - Use the Kanzi Engine API to load a Kanzi binary
When you create a new Kanzi Studio project with C++ application, Kanzi Studio creates a project with a Microsoft Visual Studio solution that includes the Kanzi application template source code.
Kanzi creates a Kanzi Studio project in <KanziWorkspace>/Projects/<ProjectName>/Tool_project directory and the structure for the Visual Studio solution for your project in <KanziWorkspace>/Projects/<ProjectName>/Application:
- bin directory contains the binaries and configuration files of your project.
- configs directory contains the configuration files for different platforms. By default Kanzi creates configuration files for several different platforms. The recommended platform for developing Kanzi applications is Microsoft Visual Studio. See Deploying Kanzi applications.
- src contains the source code for your project.
Assets for the tutorial
The starting point of this tutorial is stored in the <KanziWorkspace>/Tutorials/API tutorial directory:
- Tool_project directory contains the Kanzi Studio project which contains the application structure and resources you use in this tutorial. Whenever you make changes to this project, to see the result in your application, export the project to a kzb file. See Using kzb files.
- Application/bin directory contains the Programmer_tutorial.kzb binary file generated from the Kanzi Studio project, and .png image files that the application you create in this tutorial uses.
The <KanziWorkspace>/Examples/Programmer tutorial directory contains the completed project of this tutorial.
Use the Kanzi Engine API to load a Kanzi binary
To use the Kanzi Engine API to load a Kanzi binary:
- In Kanzi Studio open the <KanziWorkspace>/Tutorials/API tutorial/Tool_project/Programmer tutorial.kzproj Kanzi Studio project and select > Export > Export KZB.
Kanzi Studio creates the kzb file and configuration files from your Kanzi Studio project. Kanzi Studio stores the exported files in <KanziWorkspace>/Projects/<ProjectName>/Application/bin or the location you specify in the Binary Export Directory property in > . The kzb file contains all nodes and resources from your Kanzi Studio project, except the resources you mark in a localization table as locale packs.
When you run your Kanzi application from Visual Studio, your Visual Studio solution reads these files to create your Kanzi application.
- In Visual Studio open the solution stored in <KanziWorkspace>/Tutorials/API tutorial/Application/configs/platforms/win32/Programmer_tutorial.sln, set the Programmer tutorial as your startup project, and open the programmer_tutorial.cpp file.
The programmer_tutorial.cpp file contains the minimum amount of code required for loading a Kanzi application. In this tutorial you create the logic of your application in this file.
// The kanzi.hpp header includes all Kanzi Engine functionality.
// To fine-tune your application you can include only the relevant headers.
// See API reference.
#include <kanzi/kanzi.hpp>
using namespace kanzi;
class ProgrammerTutorialApplication: public ExampleApplication
{
// In the onConfigure function you can tell your Kanzi application which kzb file
// to load, enable performance information in your application, and set how many threads
// you want to use for loading the application resources.
// See Application configuration reference.
virtual void onConfigure(ApplicationProperties& configuration) KZ_OVERRIDE
{
configuration.binaryName = "Programmer_tutorial.kzb.cfg";
}
};
// To work with the main function in the Application framework you need to
// return your application in the createApplication function. The main
// function then passes the control to the main loop defined in your
// Application class.
Application* createApplication()
{
return new ProgrammerTutorialApplication;
}
-
In Visual Studio select one of the solution configurations for your version of Visual Studio and run your application.
For example, if you are still developing your application, select the GL_vs2015_Debug configuration. If you want to create a production version of your Kanzi application, select one of the available release configurations.
When you build and run the program, Kanzi loads the kzb file and shows the application content.
During an application launch Kanzi:- Calls the
onConfigure
entry point function, where you specify the configuration. For example, which Kanzi Studio project kzb files you want the application to load and the application window size. - Loads the kzb file to memory, which makes it available to the application.
- When Kanzi completes the loading of the project, it calls the
onProjectLoaded
function. In the next steps of this tutorial you add the application functionality in this function.
< INTRODUCTION
NEXT STEP >
See also
Application configuration reference
Using kzb files
Deploying Kanzi applications
API reference
Open topic with navigation